home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
-
- MODUL
- lists.c
-
- DESCRIPTION
- This file contains a complete ready-to-compile example of how to
- use lists.
-
- NOTES
-
- BUGS
-
- TODO
-
- EXAMPLES
-
- SEE ALSO
-
- INDEX
-
- HISTORY
- 30-08-95 digulla created
-
- ******************************************************************************/
-
- /**************************************
- Includes
- **************************************/
- /* This define is to enable certain features that the original AmigaOS
- lacks. The example will compile if you comment this one out so
- you can see what the advantage really is :) */
- #define AOS_ALMOST_COMPATIBLE
-
- /* All neccessary #include's for the example */
- #include <exec/lists.h>
- #include <clib/exec_protos.h>
-
- /* These are #include's neccessary to compile but not for the example
- itself */
-
-
- /**************************************
- Local Types
- **************************************/
- /* Example 1: How to use the struct List in other structures */
- typedef struct _DemoList
- {
- struct List dl_List; /* Here we collect all the nodes.
- There is no rule that this has
- to be the first thing in the
- new type, but it has advantages
- (see below). */
- UBYTE * dl_Name; /* The name of our list */
- } DemoList;
-
- /* Example 2: How to make use of the Node-structure */
- typedef struct _DemoNode
- {
- struct Node dn_Node; /* This should be the first thing
- in any node ! */
- UBYTE dn_Name[32]; /* Nodes just store a pointer to
- the name, but I want it in the
- node itself. */
- } DemoNode;
-
-
- /**************************************
- Functions
- **************************************/
-
-
- /*****************************************************************************
-
- NAME */
- int main (
-
- /* SYNOPSIS */
- int argc,
- char ** argv)
-
- /* FUNCTION
- This is the main routine for the example on how to use
- nodes.
-
- INPUTS
- None... we ignore them.
-
- RESULT
- Always 0.
-
- NOTES
-
- BUGS
-
- SEE ALSO
-
- INTERNALS
-
- HISTORY
- 30-08-95 digulla created
-
- ******************************************************************************/
- {
- /* First we need some variables to work with. Since this demo
- should show how to use lists and nodes, I do not use
- dynamic allocated memory. */
- DemoList list;
- DemoNode nodes[10];
-
- /* Before we can use a list, we have to intialize it. Since we
- have put the List-struct at the top if out new type, we
- can give the address of the variable and need not look into
- it (ie. no &list.nl_List) but we need a cast. */
- #ifdef AOS_ALMOST_COMPATIBLE
- NewList (&list);
- #else
- # ifdef USE_CAST
- NewList ((struct List *)&list);
- # else /* No cast */
- NewList (&list.dl_List);
- # endif
- #endif
-
- } /* main */
-
-
- /******************************************************************************
- ***** ENDE lists.c
- ******************************************************************************/
-